package com.idp.web.test.service.impl;

import com.idp.web.test.service.DeliverGoodsService;
import com.idp.web.test.dao.DeliverGoodsDao;
import com.idp.web.test.dao.OrdertDao;
import com.idp.web.test.entity.DeliverGoods;
import com.idp.web.test.entity.Ordert;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.idp.common.persistence.Page;
import com.idp.common.util.ResourceUtils;

/**
 * 
 * 1231232service实现类
 * 
 * <pre>
 * 	历史记录：
 * 	2017-06-02 Amber
 * 	新建文件
 * </pre>
 * 
 * @author
 * 
 *         <pre>
 * SD
 * 	Amber
 * PG
 *	Amber
 * UT
 *
 * MA
 *         </pre>
 * 
 * @version $Rev$
 *
 *          <p/>
 *          $Id$
 *
 */
@Transactional
@Service("deliverGoodsService")
public class DeliverGoodsServiceImpl implements DeliverGoodsService {

	@Resource
	private DeliverGoodsDao deliverGoodsDao;

	@Resource
	private OrdertDao ordertDao;

	@Override
	public Page<DeliverGoods> findByPage(DeliverGoods deliverGoods, Page<DeliverGoods> page) {

		page.setResult(deliverGoodsDao.find(deliverGoods, page));

		return page;
	}

	@Override
	public List<DeliverGoods> findBySearch(DeliverGoods deliverGoods) {

		return deliverGoodsDao.find(deliverGoods);
	}

	@Override
	public DeliverGoods getById(Integer id) {

		return deliverGoodsDao.getById(id);
	}

	@Override
	public void add(DeliverGoods deliverGoods) {

		deliverGoodsDao.add(deliverGoods);
		ordertDao.updateOrdertStatus(deliverGoods.getOrdertId());

	}

	@Override
	public void update(DeliverGoods deliverGoods) {

		deliverGoodsDao.update(deliverGoods);
	}

	@Override
	public void delete(Integer id) {

		deliverGoodsDao.delete(id);
	}

	@Override
	public Integer getIdByCode(String code) {
		// TODO Auto-generated method stub
		return deliverGoodsDao.getIdByCode(code);
	}

}